#! /bin/bash
#SQOOP_HOME=/opt/cloudera/parcels/CDH-6.2.1-1.cdh6.2.1.p0.1425774/bin/sqoop
export LANG=zh_CN.UTF-8
SQOOP_HOME=/usr/bin/sqoop

if [[ $1 == "" ]];then
   TD_DATE=`date -d '1 days ago' "+%Y-%m-%d"`
else
   TD_DATE=$1
fi

echo '========================================'
echo '==============开始全量导入==============='
echo '========================================'

# 全量
#/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
#--driver 'com.mysql.jdbc.Driver' \
#--connect 'jdbc:mysql://106.75.33.59:3306/yipin?enabledTLSProtocols=TLSv1.2&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
sqoop import \
--driver 'com.mysql.jdbc.Driver' \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username bjclass58 \
--password bjclass58_itcast \
--query "select *, "2022-06-06" as dt from customer where 1=1 and \$CONDITIONS" \
--hcatalog-database zy_ods \
--hcatalog-table customer \
-m 1
echo '表customer导入完成'
wait



#/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username bjclass58 \
--password bjclass58_itcast \
--query "select *,"2022-06-06" as dt from customer_relationship where 1 = 1 and \$CONDITIONS" \
--hcatalog-database zy_ods \
--hcatalog-table customer_relationship \
-m 1
echo '表customer_relationship导入完成'
wait

sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username bjclass58 \
--password bjclass58_itcast \
--query "select *,"2022-06-06" as dt from customer_appeal where 1 = 1 and \$CONDITIONS" \
--hcatalog-database zy_ods \
--hcatalog-table customer_appeal \
-m 1
echo '表customer_appeal导入完成'
wait


sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username bjclass58 \
--password bjclass58_itcast \
--query "select *,"2022-06-06" as dt from customer_clue where 1 = 1 and \$CONDITIONS" \
--hcatalog-database zy_ods \
--hcatalog-table customer_clue \
-m 1
echo '表customer_clue导入完成'
wait


sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username bjclass58 \
--password bjclass58_itcast \
--query "select *,"2022-06-06" as dt from employee where 1 = 1 and \$CONDITIONS" \
--hcatalog-database zy_ods \
--hcatalog-table employee \
-m 1
echo '表employee导入完成'
wait


sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username bjclass58 \
--password bjclass58_itcast \
--query "select *,"2022-06-06" as dt from itcast_clazz where 1 = 1 and \$CONDITIONS" \
--hcatalog-database zy_ods \
--hcatalog-table itcast_clazz \
-m 1
echo '表itcast_clazz导入完成'
wait


sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username bjclass58 \
--password bjclass58_itcast \
--query "select *,"2022-06-06" as dt from itcast_school where 1 = 1 and \$CONDITIONS" \
--hcatalog-database zy_ods \
--hcatalog-table itcast_school \
-m 1
echo '表itcast_school导入完成'
wait


sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username bjclass58 \
--password bjclass58_itcast \
--query "select *,"2022-06-06" as dt from itcast_subject where 1 = 1 and \$CONDITIONS" \
--hcatalog-database zy_ods \
--hcatalog-table itcast_subject \
-m 1
echo '表itcast_subject导入完成'
wait


sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username bjclass58 \
--password bjclass58_itcast \
--query "select *,"2022-06-06" as dt from scrm_department where 1 = 1 and \$CONDITIONS" \
--hcatalog-database zy_ods \
--hcatalog-table scrm_department \
-m 1
echo '表scrm_department导入完成'
